Bit-width control for bi-directional optical flow

ABSTRACT

A method for controlling bit-width for bi-directional optical flow (BDOF) for video coding includes encoding a first reference picture and a second reference picture, the second reference picture being different than the first reference picture, wherein the first reference picture is displayed before a current picture and the second reference picture is displayed after the current picture. A motion refinement of a coding unit (CU) is calculated by minimizing a difference between a first prediction L0 and a second prediction L1. First gradient values for the first prediction L0 and second gradient values for the second prediction L1 are calculated. A final bi-prediction of the CU is calculated. Also disclosed are an associated apparatus and an associated non-transitory computer readable storage medium.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No. 18/219,089 filed on Jul. 6, 2023, which is a continuation of U.S. patent application Ser. No. 17/726,523 filed on Apr. 21, 2022, which is a continuation of U.S. application Ser. No. 17/368,468 filed on Jul. 6, 2021, which is a continuation of PCT Application PCT/US2020/012338 filed Jan. 6, 2020, which is based on and claims the benefit of U.S. Provisional Application No. 62/788,898 filed on Jan. 6, 2019, the entire disclosures of which are incorporated herein by reference for all purposes.

FIELD

The present disclosure relates generally to coding (e.g., encoding and decoding) video data. More specifically, this disclosure relates to methods and apparatus for improving bi-directional optical flow (BDOF) processing methods for video coding. In particular example embodiments, methods are described by which a block is bi-directionally predicted from reference pictures that occur in opposite directions with respect to a current picture (e.g., a first reference picture having display order before the current picture and a second reference picture having display order after the current picture) using BDOF.

BACKGROUND

This section provides background information related to the present disclosure. The information contained within this section should not necessarily be construed as prior art.

Various video coding techniques may be used to compress video data. Video coding is performed according to one or more video coding standards. For example, video coding standards include versatile video coding (VVC), joint exploration test model coding (JEM), high-efficiency video coding (H.265/HEVC), advanced video coding (H.264/AVC), moving picture experts group coding (MPEG), or the like. Video coding generally utilizes prediction methods (e.g., inter-prediction, intra-prediction, or the like) that take advantage of redundancy present in video images or sequences. An important goal of video coding techniques is to compress video data into a form that uses a lower bit rate, while avoiding or minimizing degradations to video quality.

The first version of the HEVC standard was finalized in October 2013, which offers approximately 50% bit-rate saving or equivalent perceptual quality compared to the prior generation video coding standard H.264/MPEG AVC. Although the HEVC standard provides significant coding improvements over its predecessor, there is evidence that superior coding efficiency can be achieved with additional coding tools over HEVC. Based on that, both VCEG and MPEG started the exploration work of new coding technologies for future video coding standardization. One Joint Video Exploration Team (JVET) was formed in October 2015 by ITU-T VECG and ISO/IEC MPEG to begin significant study of advanced technologies that could enable substantial enhancement of coding efficiency. The JVET developed a reference software called joint exploration model (JEM) by integrating several additional coding tools on top of the HEVC test model (HM).

In October 2017, ITU-T and ISO/IEC issued a joint call for proposals (CfP) on video compression with capability beyond HEVC. In April 2018, 23 CfP responses were received and evaluated at the 10-th JVET meeting, which demonstrated compression efficiency gain over the HEVC of around 40%. Based on such evaluation results, the JVET launched a new project to develop the new generation video coding standard named Versatile Video Coding (VVC). In the same month, one reference software codebase, called VVC test model (VTM), was established for demonstrating a reference implementation of the VVC standard.

SUMMARY

This section provides a general summary of the disclosure, and is not a comprehensive disclosure of its full scope or all of its features.

According to a first aspect of the present disclosure, a method for controlling bit-width for bi-directional optical flow (BDOF) for video coding, performed at a computing device having one or more processors and memory storing a plurality of programs to be executed by the one or more processors, includes decoding a first reference picture and a second reference picture. The second reference picture being different than the first reference picture, wherein the first reference picture is displayed before a current picture and the second reference picture is displayed after the current picture. A first motion vector (MV₀) is determined from a current block of the current picture to a first prediction L₀ of the first reference picture. A second motion vector (MV₁) is determined from the current block to a second prediction L₁ of the second reference picture. A first temporal distance (τ₀) is determined from the current picture to the first reference picture and a second temporal distance (τ₁) is determined from the current picture to the second reference picture. A motion refinement is calculated by minimizing a difference between the first prediction L₀ and the second prediction L₁. A first gradient value and a second gradient value are calculated, wherein an additional right shift is introduced to lower an internal bit-width of the first gradient value and the second gradient value. The summation of the first gradient value and the second gradient value is calculated, wherein an additional right shift is introduced to the summation to lower its bit-width. The difference between the first prediction sample L₀ and the second prediction sample L₁ is calculated, wherein an additional right shift is introduced to the first prediction sample L₀ and the second prediction sample L₁ to lower an internal bit-width of the difference.

According to a second aspect of the present disclosure, a computing device includes one or more processors, a non-transitory storage coupled to the one or more processors, and a plurality of programs stored in the non-transitory storage. When the plurality of programs are executed by the one or more processors, the computing device decodes a first reference picture and a second reference picture. The second reference picture is different than the first reference picture, wherein the first reference picture is displayed before a current picture and the second reference picture is displayed after the current picture. A first motion vector (MV₀) is determined from a current block of the current picture to a first prediction L₀ of the first reference picture. A second motion vector (MV₁) is determined from the current block to a second prediction L₁ of the second reference picture. A first temporal distance (τ₀) is determined from the current picture to the first reference picture and a second temporal distance (τ₁) is determined from the current picture to the second reference picture. A motion refinement is calculated by minimizing a difference between the first prediction L₀ and the second prediction L₁. A first gradient value and a second gradient value are calculated, wherein an additional right shift is introduced to lower an internal bit-width of the first gradient value and the second gradient value. The summation of the first gradient value and the second gradient value is calculated, wherein an additional right shift is introduced to the summation to lower its bit-width. The difference between the first prediction sample L₀ and the second prediction sample L₁ is calculated, wherein an additional right shift is introduced to the first prediction sample L₀ and the second prediction sample L₁ to lower an internal bit-width of the difference.

According to a third aspect of the present disclosure, a non-transitory computer readable storage medium stores a plurality of programs for execution by a computing device having one or more processors. The plurality of programs, when executed by the one or more processors, cause the computing device to decode a first reference picture and a second reference picture. The second reference picture is different than the first reference picture, wherein the first reference picture is displayed before a current picture and the second reference picture is displayed after the current picture. A first motion vector (MV₀) is determined from a current block of the current picture to a first prediction L₀ of the first reference picture. A second motion vector (MV₁) is determined from the current block to a second prediction L₁ of the second reference picture. A first temporal distance (to) is determined from the current picture to the first reference picture and a second temporal distance (τ₁) is determined from the current picture to the second reference picture. A motion refinement is calculated by minimizing a difference between the first prediction L₀ and the second prediction L₁. A first gradient value and a second gradient value are calculated, wherein an additional right shift is introduced to lower an internal bit-width of the first gradient value and the second gradient value. The summation of the first gradient value and the second gradient value is calculated, wherein an additional right shift is introduced to the summation to lower its bit-width. The difference between the first prediction sample L₀ and the second prediction sample L₁ is calculated, wherein an additional right shift is introduced to the first prediction sample L₀ and the second prediction sample L₁ to lower an internal bit-width of the difference.

BRIEF DESCRIPTION OF THE DRAWINGS

Hereinafter, sets of illustrative, non-limiting embodiments of the present disclosure will be described in conjunction with the accompanying drawings. Variations of structure, method, or functionality may be implemented by those of ordinary skill in the relevant art based on the examples presented herein, and such variations are all contained within the scope of the present disclosure. In cases where no conflict is present, the teachings of different embodiments may, but need not, be combined with one another.

FIG. 1 is a block diagram of an example block-based hybrid video encoding system according to example embodiments including an example encoder suitable for use with bi-directional optical flow (BDOF) methods;

FIG. 2 is a block diagram setting of an example decoder according to example embodiments suitable for use with bi-directional optical flow (BDOF) methods;

FIGS. 3A-3E show example splitting types, namely, quaternary partitioning (FIG. 3A), horizontal binary partitioning (FIG. 3B), vertical binary partitioning (FIG. 3C), horizontal ternary partitioning (FIG. 3D), and vertical ternary partitioning (FIG. 3E), according to example embodiments;

FIG. 4 shows an example bi-directional optical flow (BDOF) model; and

FIG. 5 is a flowchart of an example method for predicting a block of video data according to example embodiments.

DETAILED DESCRIPTION

The terms used in the present disclosure are directed to illustrating particular examples, rather than to limit the present disclosure. The singular forms “a” “an” and “the” as used in the present disclosure as well as the appended claims also refer to plural forms unless other meanings are definitely contained in the context. It should be appreciated that the term “and/or” as used herein refers to any or all possible combinations of one or more associated listed items.

It shall be understood that, although the terms “first,” “second,” “third,” etc. may be used herein to describe various information, the information should not be limited by these terms. These terms are only used to distinguish one category of information from another. For example, without departing from the scope of the present disclosure, first information may be termed as second information; and similarly, second information may also be termed as first information. As used herein, the term “if” may be understood to mean “when” or “upon” or “in response to,” depending on the context.

Reference throughout this specification to “one embodiment,” “an embodiment,” “another embodiment,” or the like in the singular or plural means that one or more particular features, structures, or characteristics described in connection with an embodiment are included in at least one embodiment of the present disclosure. Thus, the appearances of the phrases “in one embodiment” or “in an embodiment,” “in another embodiment,” or the like in the singular or plural in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics in one or more embodiments may be combined in any suitable manner.

The present disclosure relates generally to coding (e.g., encoding and decoding) video data. More specifically, this disclosure relates to methods and apparatus for improving bi-directional optical flow (BDOF) processing methods for video coding. In particular example embodiments, methods are described by which, using BDOF, a block is bi-directionally predicted from reference pictures that occur in opposite directions with respect to a current picture (e.g., a first reference picture having display order before the current picture and a second reference picture having display order after the current picture).

The methods as described herein relate to improving or enhancing BDOF. BDOF may be applied during motion compensation and is used to modify a motion vector on a per pixel basis for a current block, such that pixels of the current block are predicted using corresponding offset values applied to the motion vector. In example embodiments, BDOF is used when motion vectors are used to inter-predict a block of video data of a current picture relative to reference blocks in reference pictures in opposite prediction directions with respect to the current block. Video coding methods include spatial (intra-picture) prediction and/or temporal (inter-picture) prediction to reduce or remove redundancy inherent in video sequences. For block-based video coding, a video slice (e.g., a video frame or a portion of a video frame) may be partitioned into video blocks, which may also be referred to as treeblocks, coding units (CUs), and/or coding nodes. Video blocks in an intra-coded (I) slice of a picture may be encoded using spatial prediction with respect to reference samples in neighboring blocks in the same picture. Video blocks in an inter-coded (P or B) slice of a picture may use spatial prediction with respect to reference samples in neighboring blocks in the same picture or temporal prediction with respect to reference samples in other reference pictures. Pictures may be referred to as frames, and reference pictures may be referred to as reference frames.

Spatial prediction or temporal prediction results in a predictive block for a block to be coded. Residual data represents pixel differences between the original block to be coded and the predictive block. An inter-coded block is encoded according to a motion vector that points to a block of reference samples forming the predictive block, and the residual data indicating the difference between the coded block and the predictive block. An intra-coded block is encoded according to an intra-coding mode and the residual data. For further compression, the residual data may be transformed from the pixel domain to a transform domain, resulting in residual transform coefficients, which then may be quantized. The quantized transform coefficients, initially arranged in a two-dimensional array, may be scanned in order to produce a one-dimensional vector of transform coefficients, and entropy coding may be applied to achieve even more compression.

For each inter-predicted block, a set of motion information may be available. A set of motion information may contain motion information for forward and backward prediction directions. As used herein, a forward or first prediction direction and a backward or second prediction direction are two prediction directions of a bi-directional prediction mode and the terms “forward,” “first,” “backward,” and “second” do not necessarily have a geometry meaning. Rather, these terms generally correspond to whether the reference pictures are to be displayed before (“backward”) or after (“forward”) the current picture. In example embodiments, the forward prediction direction may correspond to a reference picture list 0 (RefPicList0) and the backward prediction direction may correspond to a reference picture list 1 (RefPicList1) of a current picture.

For each prediction direction, motion information contains a reference index and a motion vector. In example embodiments, a reference index may be used to identify a reference picture in the current reference picture list (RefPicList0 or RefPicList1). A motion vector has a horizontal (x) and a vertical (y) component. In general, the horizontal component indicates a horizontal displacement within a reference picture, relative to the position of a current block in a current picture, for locating an x-coordinate of a reference block, while the vertical component indicates a vertical displacement within the reference picture, relative to the position of the current block, for locating a y-coordinate of the reference block.

Picture order count (POC) values are widely used in video coding standards to identify a display order of a picture. Although in some circumstances two pictures within one coded video sequence may have the same POC value, this typically does not happen within a coded video sequence. Thus, POC values of pictures are generally unique, and thus can uniquely identify corresponding pictures. When multiple coded video sequences are present in a bitstream, pictures having the same POC value may be closer to each other in terms of decoding order POC values of pictures are typically used for reference picture list construction, derivation of reference picture sets as in HEVC, and motion vector scaling.

Conceptually, many video coding standards are similar, including those previously mentioned in the Background section. For example, virtually all video coding standards use block-based processing and share similar video coding block diagrams to achieve video compression.

Like HEVC, the VVC is built upon the block-based hybrid video coding framework. FIG. 1 is a block diagram of a block-based hybrid video encoding system including an example encoder 100 that may use methods for bi-directional optical flow according to example embodiments. The input video signal is processed block by block (CUs). In VTM-1.0, a CU can be up to 128×128 pixels. However, different from the HEVC which partitions blocks only based on quad-trees, in the VVC, one coding tree unit (CTU) is split into CUs to adapt to varying local characteristics based on quad/binary/ternary-tree. Additionally, the concept of a multiple partition unit type in the HEVC is removed, i.e., the separation of CU, prediction unit (PU) and transform unit (TU) does not exist in the VVC anymore; instead, each CU is always used as the basic unit for both prediction and transform without further partitions. In the multi-type tree structure, one CTU is partitioned by a quad-tree structure and then each quad-tree leaf node may be further partitioned by a binary and ternary tree structure.

Referring to FIG. 1 , encoder 100, a video frame is partitioned into a plurality of video blocks for processing. For each given video block, a prediction is formed based on either an inter-prediction approach or an intra-prediction approach. In inter-prediction, one or more predictors are formed through motion estimation and motion compensation, based on pixels from previously reconstructed frames. In intra-prediction, predictors are formed based on reconstructed pixels in a current frame. Through mode decision, a best predictor may be chosen to predict a current block.

A prediction residual, representing the difference between a current video block and its predictor, is sent to a transform circuitry 102. The term “circuitry” as used herein includes hardware and software to operate the hardware. Transform circuitry 102 applies a transform, such as a discrete cosine transform (DCT) or a conceptually similar transform, to the residual block, producing a video block comprising transform coefficient values. Wavelet transforms, integer transforms, sub-band transforms, discrete sine transforms (DSTs), or other types of transforms could be used instead of a DCT. Transform circuitry 102 applies the transform to the residual block, producing a block of transform coefficients. The transform may convert the residual information from a pixel domain to a transform domain, such as a frequency domain.

The resulting transform coefficients are then sent from transform circuitry 102 to a quantization circuitry 104 for entropy reduction. Quantization circuitry 104 quantizes the transform coefficients to further reduce bit rate. The quantization process may reduce the bit depth associated with some or all of the coefficients. The degree of quantization may be modified by adjusting a quantization parameter. Quantized coefficients are then fed to an entropy coding circuitry 106 to generate a compressed video bitstream. Entropy coding circuitry 106 entropy codes the quantized transform coefficients. For example, entropy coding circuitry 106 may perform context adaptive variable length coding (CAVLC), context adaptive binary arithmetic coding (CABAC), syntax-based context-adaptive binary arithmetic coding (SBAC), probability interval partitioning entropy (PIPE) coding or another entropy coding technique. With context-based entropy coding, context may be based on neighboring blocks. Following the entropy coding by entropy coding circuitry 106, the encoded bitstream may be transmitted to another device (e.g., a video decoder) or archived for later transmission or retrieval. As shown in FIG. 1 , prediction-related information 110 from an inter-prediction circuitry and/or an intra-prediction circuitry 112, such as video block partition information, motion vectors, a reference picture index, and an intra-prediction mode, are also fed through the entropy coding circuitry 106 and saved into a compressed video bitstream 114.

In encoder 100, decoder-related circuitry is also needed in order to reconstruct pixels for the purpose of prediction. First, a prediction residual is reconstructed through an inverse quantization circuitry 116 and an inverse transform circuitry 118. This reconstructed prediction residual is combined with a block predictor 120 to generate un-filtered reconstructed pixels for a current video block. Inverse quantization circuitry 116 and inverse transform circuitry 118 apply inverse quantization and inverse transformation, respectively, to reconstruct the residual block in the pixel domain. In certain embodiments, a summer adds the reconstructed residual block to the motion compensated prediction block earlier produced by motion compensation circuitry 122 or intra-prediction circuitry 112 to produce a reconstructed video block for storage in a reference picture memory. The reconstructed video block may be used by motion estimation circuitry 124 and motion compensation circuitry 122 as a reference block to inter-code a block in a subsequent video frame.

To improve coding efficiency and visual quality, an in-loop filter is commonly used. For example, a deblocking filter is available in AVC and HEVC, as well as the current version of VVC. In HEVC, an additional in-loop filter called SAO (sample adaptive offset) is defined to further improve coding efficiency. In the now-current version of the VVC standard, yet another in-loop filter called ALF (adaptive loop filter) is being actively investigated for incorporation in the final standard. These in-loop filter operations are optional. Performing these operations helps to improve coding efficiency and visual quality. The operations may also be turned off as a decision rendered by encoder 100 to save computational complexity. It should be noted that intra-prediction is usually based on unfiltered reconstructed pixels, while inter-prediction is based on filtered reconstructed pixels if these filter options are turned on by encoder 100.

FIG. 2 is a block diagram of an example decoder 200 that may use methods for bi-directional optical flow. In example embodiments, decoder 200 is similar to the reconstruction-related section residing in encoder 100 of FIG. 1 . Referring to FIG. 2 , in decoder 200 an incoming video bitstream 201 is first decoded through an entropy decoding circuitry 202 to derive quantized coefficient levels and prediction-related information. The quantized coefficient levels are then processed through an inverse quantization circuitry 204 and an inverse transform circuitry 206 to obtain a reconstructed prediction residual. Inverse quantization circuitry 204 inverse quantizes, i.e., de-quantizes, the quantized transform coefficients provided in the bitstream and decoded by entropy decoding circuitry 202. The inverse quantization process may include use of a quantization parameter QPy calculated by decoder 200 for each video block in the video slice to determine a degree of quantization and, likewise, a degree of inverse quantization that should be applied. Inverse transform circuitry 206 applies an inverse transform, e.g., an inverse DCT, an inverse integer transform, or a conceptually similar inverse transform process, to the transform coefficients in order to produce residual blocks in the pixel domain.

A block predictor mechanism, which may be implemented in an intra/inter mode selector circuitry 208, includes an intra-prediction circuitry 210 is configured to perform an intra-prediction process and/or a motion compensation circuitry 212 configured to perform a motion compensation process based on decoded prediction information. A set of unfiltered reconstructed pixels are obtained by summing the reconstructed prediction residual from inverse transform circuitry 206 and a predictive output generated by the block predictor mechanism, using a summer 214. In situations where an in-loop filter 216 is turned on, a filtering operation is performed on these reconstructed pixels to derive the final reconstructed video for output.

When the video slice is coded as an intra-coded (I) slice, intra-prediction circuitry 210 may generate prediction data for a video block of the current video slice based on a signaled intra-prediction mode and data from previously decoded blocks of the current frame or picture. When the video frame is coded as an inter-coded (i.e., B, P or GPB) slice, motion compensation circuitry 212 produces predictive blocks for a video block of the current video slice based on the motion vectors and other syntax elements received from entropy decoding circuitry 202. The predictive blocks may be produced from one of the reference pictures within one of the reference picture lists. Decoder 200 may construct the reference frame lists, List 0 and List 1, using default construction techniques based on reference pictures stored in the reference picture memory.

Motion compensation circuitry 212 determines prediction information for a video block of the current video slice by parsing the motion vectors and other syntax elements and uses the prediction information to produce the predictive blocks for the current video block being decoded. For example, motion compensation circuitry 212 uses some of the received syntax elements to determine a prediction mode (e.g., intra-prediction or inter-prediction) used to code the video blocks of the video slice, an inter-prediction slice type (e.g., B slice, P slice, or GPB slice), construction information for one or more of the reference picture lists for the slice, motion vectors for each inter-encoded video block of the slice, inter-prediction status for each inter-coded video block of the slice, and other information to decode the video blocks in the current video slice.

Motion compensation circuitry 212 may also perform interpolation based on interpolation filters for sub-pixel precision. Motion compensation circuitry 212 may use interpolation filters as used by encoder 100 during encoding of the video blocks to calculate interpolated values for sub-integer pixels of reference blocks. In example embodiments, motion compensation circuitry 212 determines the interpolation filters used by encoder 100 from the received syntax elements and uses the interpolation filters to produce predictive blocks. Motion compensation circuitry 212 may be configured to perform any or all of the methods described in this disclosure (alone or in any combination). For example, motion compensation circuitry 212 may be configured to perform the example BDOF methods discussed herein.

In example embodiments, motion compensation circuitry 212 is configured to apply BDOF to blocks that have a first reference picture temporally before the current picture (e.g., in Reference Picture List 0) and a second reference picture temporally after the current picture (e.g., in Reference Picture List 1). In response to determining to apply BDOF to a block, motion compensation circuitry 212 may apply the methods discussed herein (e.g., with respect to the formulas described herein) to predict the block according to BDOF.

FIGS. 3A-3E shows five example splitting types, namely, quaternary partitioning (FIG. 3A), horizontal binary partitioning (FIG. 3B), vertical binary partitioning (FIG. 3C), horizontal ternary partitioning (FIG. 3D), and vertical ternary partitioning (FIG. 3E).

Referring again to FIG. 1 , spatial prediction and/or temporal prediction may be performed. Spatial prediction (or “intra-prediction”) uses pixels from the samples of already coded neighboring blocks (which are called reference samples) in the same video picture or slice to predict the current video block. Spatial prediction reduces spatial redundancy inherent in the video signal. Temporal prediction (also referred to as “inter-prediction” or “motion compensated prediction”) uses reconstructed pixels from the already coded video pictures to predict the current video block. Temporal prediction reduces temporal redundancy inherent in the video signal. A temporal prediction signal for a given CU is usually signaled by one or more motion vectors (MVs) which indicate an amount and a direction of motion between the current CU and the current CU's temporal reference. Also, if multiple reference pictures are supported, one reference picture index is additionally sent, which is used to identify from which reference picture in the reference picture store the temporal prediction signal comes. After spatial and/or temporal prediction, the mode decision block in the encoder chooses the best prediction mode, for example based on the rate-distortion optimization method. The prediction block is then subtracted from the current video block and the prediction residual is de-correlated using transform and quantized. The quantized residual coefficients are inverse quantized and inverse transformed to form the reconstructed residual, which is then added back to the prediction block to form the reconstructed signal of the CU. Further in-loop filtering, using a deblocking filter, such as a sample adaptive offset (SAO) and adaptive in-loop filter (ALF) for example, may be applied to the reconstructed CU before the reconstructed CU is placed in the reference picture store and used to code future video blocks. To form the output video bit-stream, a coding mode (inter or intra), prediction mode information, motion information, and quantized residual coefficients are all sent to entropy coding circuitry 106 to be further compressed and packed to form the bit-stream.

FIG. 4 shows an example bi-directional optical flow (BDOF) model. As shown in FIG. 4 , a first prediction, L₀, in a first reference block, I₀, is positioned at a first temporal distance, τ₀, from a current block, CurBlk, for which the prediction is performed. A first motion vector, A, having motion vector components, (V_(x), V_(y)), is located in first reference block I₀. Similarly, a second prediction, L₁, in a second reference block, I₁, is positioned at a second temporal distance, τ₁, from the current block. A second motion vector, B, having motion vector components, (−V_(x), −V_(y)), is located in second reference block I₁.

Bi-Directional Optical Flow: Conventional bi-prediction in video coding is a simple combination of two temporal prediction blocks obtained from the reference pictures that are already reconstructed. However, due to the limitation of the block-based motion compensation, there may be remaining small motion that can be observed between the samples of two prediction blocks, thus reducing the efficiency of motion compensated prediction. To solve this problem, bi-directional optical flow (BDOF) is applied in the VVC to lower the impact of such motion for every sample inside one block. More specifically, as shown in FIG. 4 , the BDOF is sample-wise motion refinement that is performed on top of the block-based motion-compensated predictions when bi-prediction is used. The motion refinement (v_(x), v_(y)) of each 4×4 sub-block is calculated by minimizing a difference between L₀ and L₁ prediction samples after the BDOF is applied inside one 6×6 window Ω around the sub-block. More specifically, the value of (v_(x), v_(y)) is derived as:

v _(x) =S ₁>0? clip3(−th _(BDOF) ,th _(BDOF),−((S ₃·2^(n) ^(c) )>>└log₂ S ₁┘)): 0

v _(y) =S ₅>0? clip3(−th _(BDOF) ,th _(BDOF),−((S ₆·2^(n) ^(c) −((v _(x) S _(2,m))<<n _(S) ₂ +v _(x) S _(2,s)/2)>>└log₂ S ₅┘)):0,   Eq.(1)

where └⋅┘ is the floor function; clip3 (min, max, x) is a function that clips a given value x inside the range of [min, max]; the symbol >> represents bitwise right shift operation; the symbol << represents bitwise left shift operation; th_(BDOF) is the motion refinement threshold to prevent propagated errors due to irregular local motion, which is equal to 2^(13-BD), where BD is the bit-depth of input video. In Eq. (1), S_(2,m)=S₂>>n_(S) ₂ ,

S_(2, s) = S₂&(2^(n_(S₂)) − 1).

The values of S₁, S₂, S₃, S₅, and S₆ are calculated as:

S ₁=Σ_((i,j)∈Ω)ψ_(x)(i,j)·ψ_(x)(i,j),S ₃=Σ_((i,j)∈Ω)θ(i,j)·ψ_(x)(i,j)

S ₂=Σ_((i,j)∈Ω)ψ_(x)(i,j)·ψ_(y)(i,j)

S ₅=Σ_((i,j)∈Ω)ψ_(y)(i,j)·ψ_(y)(i,j)S ₆=Σ_((i,j)∈Ω)θ(i,j)·ψ_(y)(i,j)   Eq.(2)

wherein Ω is a set of neighboring prediction samples around one subblock of prediction L₀ and L₁ and where

$\begin{matrix} {{\psi_{x}\left( {i,j} \right)} = {\left( {{\frac{\partial I^{(1)}}{\partial x}\left( {i,j} \right)} + {\frac{\partial I^{(0)}}{\partial x}\left( {i,j} \right)}} \right) \gg 3}} & {{Eq}.(3)} \end{matrix}$ ${\psi_{y}\left( {i,j} \right)} = {\left( {{\frac{\partial I^{(1)}}{\partial y}\left( {i,j} \right)} + {\frac{\partial I^{(0)}}{\partial y}\left( {i,j} \right)}} \right) \gg 3}$ θ(i, j) = (I⁽¹⁾(i, j) ≫ 6) − (I⁽⁰⁾(i, j) ≫ 6)

where I^((k))(i, j) are the prediction sample at sample location (i,j) of the prediction signal in list k, k=0, 1, which are generated at intermediate high precision (i.e., 16-bit);

$\frac{\partial I^{(k)}}{\partial x}\left( {i,j} \right){and}\frac{\partial I^{(k)}}{\partial y}\left( {i,j} \right)$

are the horizontal gradient and the vertical gradient, respectively, of the sample that are obtained by directly calculating the difference between its two neighboring samples, i.e.,

$\begin{matrix} {{\frac{\partial I^{(k)}}{\partial x}\left( {i,j} \right)} = {\left( {{I^{(k)}\left( {{i + 1},j} \right)} - {I^{(k)}\left( {{i - 1},j} \right)}} \right) \gg 4}} & {{Eq}.(4)} \end{matrix}$ ${\frac{\partial I^{(k)}}{\partial y}\left( {i,j} \right)} = {\left( {{I^{(k)}\left( {i,{j + 1}} \right)} - {I^{(k)}\left( {i,{j - 1}} \right)}} \right) \gg 4}$

Based on the motion refinement derived in Eq. (1), the final bi-prediction samples of the CU are calculated by interpolating the L₀ prediction and the L₁ prediction along the motion trajectory based on the optical flow model, as indicated by:

$\begin{matrix} {{{pred}_{BDOF}\left( {x,y} \right)} = {\left( {{I^{(0)}\left( {x,y} \right)} + {I^{(1)}\left( {x,y} \right)} + b + o_{offset}} \right) \gg {shift}}} & {{Eq}.(5)} \end{matrix}$ $b = {{{rnd}\left( {\left( {v_{x}\left( {\frac{\partial{I^{(1)}\left( {x,y} \right)}}{\partial x} - \frac{\partial{I^{(0)}\left( {x,y} \right)}}{\partial x}} \right)} \right)/2} \right)} + {{rnd}\left( {\left( {v_{y}\left( {\frac{\partial{I^{(1)}\left( {x,y} \right)}}{\partial y} - \frac{\partial{I^{(0)}\left( {x,y} \right)}}{\partial y}} \right)} \right)/2} \right)}}$

where shift and o_(offset) are the right shift value and the offset value that are applied to combine the L₀ prediction signal and the L₁ prediction signal for bi-prediction, which are equal to 15−BD and 1<<(14−BD)+2·(1<<13), respectively. Table 1 illustrates specific bit-widths of intermediate parameters that are involved in the BDOF process. As shown in Table 1, an internal bit-width of the whole BDOF process does not exceed 32-bit. Additionally, the multiplication with the worst possible input happens at the product of v_(x)S_(2,m) in Eq. (1) with input bit-width of 15-bit and 4-bit, respectively, for S_(2,m) and v_(x). Therefore, a 15-bit multiplier is sufficient for the BDOF.

TABLE 1 Bit-Widths of Intermediate Parameters of the BDOF in the VVC Bit- Operation Parameter Width L₀/L₁ I⁽⁰⁾(i, j), I⁽¹⁾(i, j) 16 Prediction Gradient Derivation ${\frac{\partial I^{(0)}}{\partial x}\left( {i,j} \right)},{\frac{\partial I^{(0)}}{\partial y}\left( {i,j} \right)}$ 13 ${\frac{\partial I^{(1)}}{\partial x}\left( {i,j} \right)},{\frac{\partial I^{(1)}}{\partial y}\left( {i,j} \right)}$ 13 Correlation Parameter Calculation θ(i, j) = (I⁽¹⁾(i, j) » 6) − (I⁽⁰⁾(i, j) » 6)   ${\psi_{x}\left( {i,j} \right)} = {\left( {{\frac{\partial I^{(1)}}{\partial x}\left( {i,j} \right)} + {\frac{\partial I^{(0)}}{\partial x}\left( {i,j} \right)}} \right) \gg 3}$ 11   11 ${\psi_{y}\left( {i,j} \right)} = {\left( {{\frac{\partial I^{(1)}}{\partial y}\left( {i,j} \right)} + {\frac{\partial I^{(0)}}{\partial y}\left( {i,j} \right)}} \right) \gg 3}$ 11 ψ_(x)(i, j) · ψ_(x)(i, j) 21 ψ_(x)(i, j) · ψ_(y)(i, j) 21 θ(i, j) · ψ_(x)(i, j) 21 ψ_(y)(i, j) · ψ_(y)(i, j) 21 θ(i, j) · ψ_(y)(i, j) 21 Summation $S_{1} = {\sum\limits_{{({i,j})} \in \Omega}{{\psi_{x}\left( {i,j} \right)} \cdot {\psi_{x}\left( {i,j} \right)}}}$ 27 $S_{2} = {\sum\limits_{{({i,j})} \in \Omega}{{\psi_{x}\left( {i,j} \right)} \cdot {\psi_{y}\left( {i,j} \right)}}}$ 27 $S_{3} = {\sum\limits_{{({i,j})} \in \Omega}{{\theta\left( {i,j} \right)} \cdot {\psi_{x}\left( {i,j} \right)}}}$ 27 $S_{5} = {\sum\limits_{{({i,j})} \in \Omega}{{\psi_{y}\left( {i,j} \right)} \cdot {\psi_{y}\left( {i,j} \right)}}}$ 27 $S_{6} = {\sum\limits_{{({i,j})} \in \Omega}{{\theta\left( {i,j} \right)} \cdot {\psi_{y}\left( {i,j} \right)}}}$ 27 Motion v_(x) = S₁ > 0? clip3 (−th_(BIO)′, th_(BIO)′, − 4 Refinement ((S₃ · 2³) >> └log₂ S₁┘)) : 0 Derivation S_(2,m) = S₂ >> 12 15 S_(2,s) = S₂&(2¹² − 1) 12 ((v_(x)S_(2,m)) << 12 + v_(x)S_(2,s))/2 30 S₆ · 2³ − ((v_(x)S_(2,m)) << 12 + v_(x)S_(2,s))/2 31 v_(y) = S₅ > 0? clip3 (−th_(BIO)′, th_(BIO)′, − 4 ((S₆ · 2³ − ((v_(x)S_(2,m)) << 12 + v_(x)S_(2,s))/2) >> └log₂ S₅┘)) : 0 Final Bi- Prediction Generation $v_{x} \cdot \left( {{\frac{\partial I^{(1)}}{\partial x}\left( {i,j} \right)} - {\frac{\partial I^{(0)}}{\partial x}\left( {i,j} \right)}} \right)$ 17 $v_{y} \cdot \left( {{\frac{\partial I^{(1)}}{\partial y}\left( {i,j} \right)} - {\frac{\partial I^{(0)}}{\partial y}\left( {i,j} \right)}} \right)$ 17

Although the BDOF may enhance the efficiency of bi-directional prediction, there is opportunity to further improve the design of the BDOF. More specifically, the following issues in the existing BDOF design in VVC for controlling the bit-widths of intermediate parameters are identified in this disclosure.

First, as shown in Table 1, the parameter θ(i,j) (i.e., the difference between L₀ and L₁ predictions), and the parameter ψ_(x)(i, j) and ψ_(y)(i, j) (i.e., the sum of the horizontal gradient value and the vertical gradient value for L₀ and L₁) are represented in the same bit-width of 11-bit. Although such method may facilitate an overall control of the internal bit-width for the BDOF, this method may be suboptimal with regards to the precision of the derived motion refinements. This is because as shown in Eq. (4), the gradient values are calculated as a difference between neighboring predictions. Due to the high-pass nature of such process, the derived gradients are less reliable in the presence of noise, e.g., the noise captured in an original video and the coding noise that is generated during the coding process. This means that it may not always be beneficial to represent the gradient values in high bit-width.

Additionally, as shown in Table 1, the maximum bit-width usage of the whole BDOF process occurs with a calculation of the vertical motion refinement v_(y) where S₆ (27-bit) is firstly left-shifted by 3-bit and then is subtracted by ((v_(x)S_(2,m))<<12+v_(x)S_(2,s))/2 (30-bit). Therefore, the maximum bit-width of the current design is equal to 31-bit. In practical hardware implementation, the coding process with maximum internal bit-width more than 16-bit is usually implemented by 32-bit implementation. Therefore, the existing design does not fully utilize the valid dynamic range of the 32-bit implementation. This may lead to unnecessary precision loss of the motion refinements derived by the BDOF.

In example embodiments, such as the example method as shown in FIG. 5 , an example bit-width control method addresses the above issues of the bit-width control method for conventional BDOF design.

Firstly, to overcome the negative impacts of gradient estimation errors, an additional right shift n_(grad) is introduced in an example embodiment when calculating the gradient values

$\frac{\partial I^{(k)}}{\partial x}\left( {i,j} \right){and}\frac{\partial I^{(k)}}{\partial y}\left( {i,j} \right)$

in Eq. (4), i.e., to lower the internal bit-width of gradient values. More specifically, the first gradient values, i.e., the horizontal gradient and the vertical gradient, at the first prediction position

$L_{0}\left( {\frac{\partial I^{(0)}}{\partial x}\left( {i,j} \right){and}\frac{\partial I^{(0)}}{\partial y}\left( {i,j} \right)} \right)$

and the second gradient values i.e. the horizontal gradient and the vertical gradient, at the second prediction position

$L_{1}\left( {\frac{\partial I^{(1)}}{\partial x}\left( {i,j} \right){and}\frac{\partial I^{(1)}}{\partial y}\left( {i,j} \right)} \right)$

are calculated as:

$\begin{matrix} {{{\frac{\partial I^{(k)}}{\partial x}\left( {i,j} \right)} = {\left( {{I^{(k)}\left( {{i + 1},j} \right)} - {I^{(k)}\left( {{i - 1},j} \right)}} \right) \gg \left( {4 + n_{grad}} \right)}},{k = 0},1} & {{Eq}.(6)} \end{matrix}$ ${{\frac{\partial I^{(k)}}{\partial y}\left( {i,j} \right)} = {\left( {{I^{(k)}\left( {i,{j + 1}} \right)} - {I^{(k)}\left( {i,{j - 1}} \right)}} \right) \gg \left( {4 + n_{grad}} \right)}},{k = 0},1$

Moreover, an additional bit-shift n_(adj) is introduced to the calculation of variables ψ_(x)(i,j), ψ_(y)(i,j) and θ(i,j) in order to control the entire BDOF process so that the BDOF process is operated at appropriate internal bit-widths, as depicted as:

$\begin{matrix} {{\psi_{x}\left( {i,j} \right)} = {\left( {{\frac{\partial I^{(1)}}{\partial x}\left( {i,j} \right)} + {\frac{\partial I^{(0)}}{\partial x}\left( {i,j} \right)}} \right) \gg \left( {3 - n_{adj}} \right)}} & {{Eq}.(7)} \end{matrix}$ ${\psi_{y}\left( {i,j} \right)} = {\left( {{\frac{\partial I^{(1)}}{\partial y}\left( {i,j} \right)} + {\frac{\partial I^{(0)}}{\partial y}\left( {i,j} \right)}} \right) \gg \left( {3 - n_{adj}} \right)}$ θ(i, j) = (I⁽¹⁾(i, j) ≫ (6 − n_(adj))) − (I⁽⁰⁾(i, j) ≫ 6 − n_(adj))).

Table 2 below shows the corresponding bit-width of each intermediate parameter when the example bit-width control method is applied to the BDOF. Table 2 shows changes that are applied in the example bit-width control method compared to the conventional BDOF design in VVC. As can be seen in Table 2, with the example bit-width control method, the internal bit-width of the whole BDOF process does not exceed 32-bit. Additionally, by the example method, the maximum bit-width is just 32-bit, which can fully utilize the available dynamic range of 32-bit hardware implementation. Further, as shown in Table 2, the multiplication with the worst possible input happens at the product of v_(x)S_(2,m) where the input S_(2,m) is 14-bit and the input v_(x) is 6-bit. Therefore, like conventional BDOF methods, one 16-bit multiplier is also sufficiently large when the example method is applied.

Referring to Table 2, due to the modification to the number of right-shifted bits that are applied in Eq. (6) and Eq. (7), the dynamic ranges of the parameters ψ_(x)(i,j), ψ_(y)(i,j) and θ(i,j) are different, compared to conventional BDOF methods shown in Table 1, where the three parameters are represented in the same dynamic range (i.e., 21-bit). Such change may increase the bit-widths of the internal parameters S₁, S₂, S₃, S₅, and S₆, which may potentially increase the maximum bit-width of the internal BDOF process to greater than 32-bit. Thus, to ensure a 32-bit implementation, two additional clipping operations are introduced in calculating the values of S₂ and S₆. More specifically, in the example method, the values of two parameters are calculated as:

S ₂=Clip3(−2^(B) ² ,2^(B) ² −1,Σ_((i,j)∈Ω)ψ_(x)(i,j)·ψ_(y)(i,j))

S ₆=Clip3(−2^(B) ⁶ ,2^(B) ⁶ −1,Σ_((i,j)∈Ω)θ(i,j)·ψ_(y)(i,j)),  Eq.(8)

wherein B₂ and B₆ are the parameters to control the output dynamic ranges of S₂ and S₆, respectively. It should be noticed that different from the gradient calculation the clipping operations in Eq. (8) are only applied once to calculate the motion refinement of each 4×4 sub-block inside one BDOF CU, i.e., being invoked based on the 4×4 unit. Therefore, the corresponding complexity increase due to the clipping operations introduced in the proposed method is very negligible.

In example embodiments, the final bi-prediction of the CU is calculated based on the first prediction L₀ and the second prediction L₁, the motion refinement (v_(x), v_(y)) and the first gradient values

$\frac{\partial I^{(0)}}{\partial x}\left( {i,j} \right){and}\frac{\partial I^{(0)}}{\partial y}\left( {i,j} \right)$

and second gradient values

$\frac{\partial I^{(1)}}{\partial x}\left( {i,j} \right){and}\frac{\partial I^{(1)}}{\partial y}{\left( {i,j} \right).}$

In practice, different values of n_(grad), n_(adj), B₂, and B₆ may be applied to achieve different trade-offs between the intermediate bit-width and the precision of internal BDOF derivations. In one example embodiment, n_(grad) and n_(adj) are set to 2, B₂ is set to 25 and B₆ is set to 27. In certain example embodiments, the value of n_(c) is set equal to 2 and/or th_(BDOF) is set equal to 2 (see Eq. (1)), for example.

TABLE 2 Bit-Widths of Intermediate Parameters of Example Method Bit- Operation Parameter Width L₀/L₁ Prediction I⁽⁰⁾(i, j), I⁽¹⁾(i, j) 16 Gradient Derivation ${\frac{\partial I^{(0)}}{\partial x}\left( {i,j} \right)},{\frac{\partial I^{(0)}}{\partial y}\left( {i,j} \right)}$ 11 ${\frac{\partial I^{(1)}}{\partial x}\left( {i,j} \right)},{\frac{\partial I^{(1)}}{\partial y}\left( {i,j} \right)}$ 11 Correlation Parameter Calculation θ(i, j) = (I⁽¹⁾(i, j) >> 4) − (I⁽⁰⁾(i, j) >> 4)   ${\psi_{x}\left( {i,j} \right)} = {\left( {{\frac{\partial I^{(1)}}{\partial x}\left( {i,j} \right)} + {\frac{\partial I^{(0)}}{\partial x}\left( {i,j} \right)}} \right) \gg 1}$ 13   11 ${\psi_{y}\left( {i,j} \right)} = {\left( {{\frac{\partial I^{(1)}}{\partial y}\left( {i,j} \right)} + {\frac{\partial I^{(0)}}{\partial y}\left( {i,j} \right)}} \right) \gg 1}$ 11 ψ_(x)(i, j) · ψ_(x)(i, j) 21 ψ_(x)(i, j) · ψ_(y)(i, j) 21 θ(i, j) · ψ_(x)(i, j) 23 ψ_(y)(i, j) · ψ_(y)(i, j) 21 θ(i, j) · ψ_(y)(i, j) 23 Summation $S_{1} = {\sum\limits_{{({i,j})} \in \Omega}{{\psi_{x}\left( {i,j} \right)} \cdot {\psi_{x}\left( {i,j} \right)}}}$ 27 $S_{2} = {{Clip}3\left( {{- 2^{25}},{2^{25} - 1},{\sum\limits_{{({i,j})} \in \Omega}{{\psi_{x}\left( {i,j} \right)} \cdot {\psi_{y}\left( {i,j} \right)}}}} \right)}$ 26 $S_{3} = {\sum\limits_{{({i,j})} \in \Omega}{{\theta\left( {i,j} \right)} \cdot {\psi_{x}\left( {i,j} \right)}}}$ 29 $S_{5} = {\sum\limits_{{({i,j})} \in \Omega}{{\psi_{y}\left( {i,j} \right)} \cdot {\psi_{y}\left( {i,j} \right)}}}$ 27 $S_{6} = {{Clip}3\left( {{- 2^{27}},{2^{27} - 1},{\sum\limits_{{({i,j})} \in \Omega}{{\theta\left( {i,j} \right)} \cdot {\psi_{y}\left( {i,j} \right)}}}} \right)}$ 28 Motion v_(x) = S₁ > 0? clip3 (−th_(BDOF)′, th_(BDOF)′, − 6 Refinement ((S₃ · 2³) >> └log₂ S₁┘)) : 0 Derivation S_(2,m) = S₂ >> 12 14 S_(2,s) = S₂&(2¹² − 1) 12 ((v_(x)S_(2,m)) << 12 + v_(x)S_(2,s))/2 31 S₆ · 2³ − ((v_(x)S_(2,m)) << 12 + v_(x)S_(2,s))/2 32 v_(y) = S₅ > 0? clip3 (−th_(BDOF)′, th_(BDOF)′, − 6 ((S₆ · 2³ − ((v_(x)S_(2,m)) << 12 + v_(x)S_(2,s))/2) >> └log₂ S₅┘)) : 0 Final Bi- Prediction Generation $v_{x} \cdot \left( {{\frac{\partial I^{(1)}}{\partial x}\left( {i,j} \right)} - {\frac{\partial I^{(0)}}{\partial x}\left( {i,j} \right)}} \right)$ 17 $v_{y} \cdot \left( {{\frac{\partial I^{(1)}}{\partial y}\left( {i,j} \right)} - {\frac{\partial I^{(0)}}{\partial y}\left( {i,j} \right)}} \right)$ 17

FIG. 5 is a flowchart for an example method 300 for predicting a block of video data according to example embodiments. The method shown in FIG. 5 is explained with respect to encoder 100 of FIG. 1 and/or decoder 200 of FIG. 2 . However, in other examples, other devices may be configured to perform the method shown in FIG. 5 .

In example embodiments, encoder 100 initially encodes, and then subsequently decodes, pictures for use as reference pictures, stored in a reference picture memory, although these steps are not illustrated in the example method of FIG. 5 . Encoder 100 then receives a block of video data. The block may be, for example, a prediction unit (PU) of a coding unit (CU) of a current picture (or a slice of the picture) of video data. Encoder 100 may determine which of a variety of prediction modes to use to predict the block, such as intra-prediction or inter-prediction, and if inter-prediction is determined, whether to use uni-directional or bi-directional inter-prediction. In the example method of FIG. 5 , encoder 100 determines to predict the block using bi-prediction. For example, encoder 100 may calculate rate-distortion metrics for various possible prediction modes (e.g., one or more intra-prediction modes and uni-directional or bi-directional prediction from the various decoded reference pictures stored in the reference picture memory) and determine that bi-prediction yields the best rate-distortion metrics for the block.

Encoder 100, e.g., motion estimation circuitry 124, may further calculate motion vectors for the block according to bi-prediction. Such motion vectors may refer to a first reference picture to be displayed before the current picture and a second reference picture to be displayed after the current picture. For example, the first reference picture may occur in reference picture list 0 (RefPicList0) and the second reference picture may occur in reference picture list 1 (RetPicList1).

In one embodiment, encoder 100 determines a first POC difference between a POC value for the current picture and a POC value for a first reference picture, to which a first motion vector (MV₀) refers, at a first temporal distance τ₀, and a second POC difference between the POC value for the current picture and a POC value for a second reference picture, to which a second motion vector (MV₁) refers, at a second temporal distance τ₁. MV₀ and MV₁ may include a respective x-component and y-component. For example, MV₀ may include MV_(x0) and MV_(y0) components, where MV_(x0) describes a horizontal offset and MV_(y0) describes a vertical offset relative to the position of the block in the current picture to determine a position at which to locate a reference block in the first reference picture. Similarly, MV₁ may include MV_(x1) and MV_(y1) components, where MV_(x1) describes a horizontal offset and MV_(y1) describes a vertical offset relative to the position of the block in the current picture to determine a position at which to locate a reference block in the second reference picture.

In example embodiments, a first reference picture and a second reference picture are decoded 302. The second reference picture is different than the first reference picture, wherein the first reference picture is displayed before a current picture and the second reference picture is displayed after the current picture. In example embodiments, a first motion vector (MV₀) from a current block of the current picture to a first prediction L₀ of the first reference picture is determined 304 and a second motion vector (MV₁) from the current block to a second prediction L₁ of the second reference picture is determined 306. In certain example embodiments, a first motion vector (MV₀) from a current block of the current picture to a first prediction L₀ of the first reference picture at a first temporal distance (τ₀) from the current picture to the first reference picture is determined and a second motion vector (MV₁) from the current block to a second prediction L₁ of the second reference picture at a second temporal distance (τ₁) from the current picture to the second reference picture is determined.

Encoder 100 then uses these values to calculate 308 a motion refinement (v_(x), v_(y)) of a coding unit (CU) by minimizing a difference between the first prediction L₀ and the second prediction L₁. In example embodiments, first gradient values

$\frac{\partial I^{(0)}}{\partial x}\left( {i,j} \right){and}\frac{\partial I^{(0)}}{\partial y}\left( {i,j} \right)$

for the first prediction L₀ and second gradient values

$\frac{\partial I^{(1)}}{\partial x}\left( {i,j} \right){and}\frac{\partial I^{(1)}}{\partial y}\left( {i,j} \right)$

for the second prediction L₁ are calculated 310. In example embodiments, first gradient values and second gradient values can then be calculated by introducing an additional right shift n_(grad) to lower an internal bit-width of the first gradient values and the second gradient values, as shown in Eq. (6). In example embodiments, calculating 310 the first gradient value and the second gradient value includes calculating a horizontal gradient and a vertical gradient at each of a first prediction position of the first prediction and a second prediction position of the second prediction. Referring to Eq. (6) the horizontal gradient is calculated at each of the first prediction position and the second prediction position, and the vertical gradient is calculated at each of the first prediction position and the second prediction position.

In example embodiments, the value of (v_(x), v_(y)) is calculated using Eq. (1), wherein an additional bit-shift n_(adj) is introduced to a calculation of a plurality of variables ψ_(x)(i,j), ψ_(y)(i,j), and θ(i,j), as shown in Eq. (7), in order to calculate the value of S₁, S₂, S₃, S₄, and S₆. For example, the value of S₂ and S₆ are calculated using Eq. (8). In example embodiments, the value of S₂ and S₆ are calculated by introducing a first clipping operation and a second clipping operation as shown in Eq. (8), wherein B₂ is a parameter to control an output dynamic range of S₂ and B₆ is a parameter to control an output dynamic range of S₆. A final bi-prediction of the CU may then be calculated 312 based on the first prediction L₀ and the second prediction L₁, the motion refinement (v_(x), v_(y)), the first gradient values

${\frac{\partial I^{(0)}}{\partial x}\left( {i,j} \right){and}\frac{\partial I^{(0)}}{\partial y}\left( {i,j} \right)},$

and the second gradient values

$\frac{\partial I^{(1)}}{\partial x}\left( {i,j} \right){and}\frac{\partial I^{(1)}}{\partial y}{\left( {i,j} \right).}$

In certain example embodiments, the final bi-prediction samples of the CU can then be calculated based on the motion refinement by interpolating the first prediction L₀ and/or the second prediction L₁ along a motion trajectory, as indicated in Eq. (5). In example embodiments, the summation of the first gradient value and the second gradient value is calculated, wherein an additional right shift is introduced to the summation to lower its bit-width. The difference between the first prediction sample L₀ and the second prediction sample L₁ is calculated, wherein an additional right shift is introduced to the first prediction sample L₀ and the second prediction sample L₁ to lower an internal bit-width of the difference.

The example method shown in FIG. 5 represents an example of a method of encoding video data including decoding a first reference picture and a second reference picture, the second reference picture being different than the first reference picture, wherein the first reference picture is to be displayed before a current picture and the second reference picture is to be displayed after the current picture, determining a first motion vector (MV₀) from a current block of the current picture to a first reference block of the first reference picture, determining a second motion vector (MV₁) from the current block to a second reference block of the second reference picture, and encoding the current block according to bi-directional optical flow (BDOF).

In one or more examples, the functions described may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored on or transmitted over, as one or more instructions or code, a computer-readable medium and executed by a hardware-based processing unit. Computer-readable media may include computer-readable storage media, which corresponds to a tangible medium such as data storage media, or communication media including any medium that facilitates transfer of a computer program from one place to another, e.g., according to a communication protocol. In this manner, computer-readable media generally may correspond to (1) tangible computer-readable storage media which is non-transitory or (2) a communication medium such as a signal or carrier wave. Data storage media may be any available media that can be accessed by one or more computers or one or more processors to retrieve instructions, code and/or data structures for implementation of the implementations described in the present application. A computer program product may include a computer-readable medium.

Further, the above methods may be implemented using an apparatus that includes one or more circuitries, which include application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, micro-controllers, microprocessors, or other electronic components. The apparatus may use the circuitries in combination with the other hardware or software components for performing the above described methods. Each module, sub-module, unit, or sub-unit disclosed above may be implemented at least partially using the one or more circuitries.

Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed here. This application is intended to cover any variations, uses, or adaptations of the invention following the general principles thereof and including such departures from the present disclosure as come within known or customary practice in the art. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.

It will be appreciated that the present invention is not limited to the exact examples described above and illustrated in the accompanying drawings, and that various modifications and changes can be made without departing from the scope thereof. It is intended that the scope of the invention only be limited by the appended claims. 

What is claimed is:
 1. A method for video encoding, comprising: obtaining a current block from a current picture; determining, for the current block, a first prediction corresponding to a first reference picture, wherein the first reference picture is displayed before the current picture; determining, for the current block, a second prediction corresponding to a second reference picture, wherein the second reference picture is displayed after the current picture; calculating first gradient values for the first prediction and second gradient values for the second prediction; calculating a respective motion refinement of each subblock of the current block by minimizing a difference between the first prediction and the second prediction based on a motion refinement threshold and a plurality of internal parameters representing different summation characters of the first prediction and the second prediction; calculating a final bi-prediction of the current block based on the first prediction, the second prediction, respective motion refinements, the first gradient values and the second gradient values; and generating a video bitstream based on the final bi-prediction.
 2. The method of claim 1, wherein calculating a respective motion refinement of each subblock of the current block by minimizing a difference between the first prediction and the second prediction comprises: calculating a horizontal summation by adding a first horizontal gradient and a second horizontal gradient, and calculating a vertical summation by adding a first vertical gradient and a second vertical gradient, wherein a first right shift value is introduced into the horizontal summation and the vertical summation for lowering a bit-width of each of the horizontal summation and the vertical summation; and calculating a respective motion refinement of each subblock of the current block based on the horizontal summation and the vertical summation.
 3. The method of claim 1, wherein a second right shift value is introduced into the calculation of the first gradient values for the first prediction and the calculation of the second gradient values for the second prediction.
 4. The method of claim 1, wherein calculating a respective motion refinement of each subblock of the current block by minimizing a difference between the first prediction and the second prediction comprises: clipping a horizontal motion refinement and a vertical motion refinement in the respective motion refinement to a range of [−th_(BDOF), th_(BDOF)], wherein th_(BDOF) is a motion refinement threshold, and wherein the respective motion refinement comprises the horizontal motion refinement and the vertical motion refinement.
 5. The method of claim 1, wherein a third right shift value is introduced into the calculation of the difference between the first prediction and the second prediction.
 6. The method of claim 1, wherein calculating the first gradient values for the first prediction and the second gradient values for the second prediction further comprises calculating a horizontal gradient and a vertical gradient at each of a first prediction position of the first prediction and a second prediction position of the second prediction.
 7. The method of claim 1, wherein calculating the final bi-prediction of the current block comprises: calculating the final bi-prediction of the current block based further on a fourth right shift value for combining the first prediction and the second prediction.
 8. The method of claim 7, wherein the fourth right shift value comprises an additional right shift value, and wherein the additional right shift value is set to be equal to a bit-depth of a video for decoding.
 9. The method of claim 1, wherein the first prediction is determined based on a first motion vector from the current block to the first reference picture, and wherein the second prediction is determined based on a second motion vector from the current block to the second reference picture.
 10. A computing device, comprising: one or more processors; a non-transitory storage coupled to the one or more processors; and a plurality of programs stored in the non-transitory storage that, when executed by the one or more processors individually or collectively, cause the computing device to perform acts comprising: obtaining a current block from a current picture; determining, for the current block of, a first prediction corresponding to a first reference picture, wherein the first reference picture is displayed before the current picture; determining, for the current block, a second prediction corresponding to a second reference picture, wherein the second reference picture is displayed after the current picture; calculating first gradient values for the first prediction and second gradient values for the second prediction; calculating a respective motion refinement of each subblock of the current block by minimizing a difference between the first prediction and the second prediction based on a motion refinement threshold and a plurality of internal parameters representing different summation characters of the first prediction and the second prediction; calculating a final bi-prediction of the current block based on the first prediction, the second prediction, respective motion refinements, the first gradient values, and the second gradient values; and generating a video bitstream based on the final bi-prediction.
 11. The computing device of claim 10, calculating a respective motion refinement of each subblock of the current block by minimizing a difference between the first prediction and the second prediction comprises: calculating a horizontal summation by adding a first horizontal gradient and a second horizontal gradient, and calculating a vertical summation by adding a first vertical gradient and a second vertical gradient, wherein a first right shift value is introduced into the horizontal summation and the vertical summation for lowering a bit-width of each of the horizontal summation and the vertical summation; and calculating a respective motion refinement of each subblock of the current block based on the horizontal summation and the vertical summation.
 12. The computing device of claim 10, wherein a first right shift value is introduced into the calculation of both the first gradient values for the first prediction and the calculation of the second gradient values for the second prediction.
 13. The computing device of claim 10, wherein calculating a respective motion refinement of each subblock of the current block by minimizing a difference between the first prediction and the second prediction comprises: clipping a horizontal motion refinement and a vertical motion refinement in the respective motion refinement to a range of [−th_(BDOF), th_(BDOF)], wherein th_(BDOF) is a motion refinement threshold, and wherein the respective motion refinement comprises the horizontal motion refinement and the vertical motion refinement.
 14. The computing device of claim 10, wherein a second right shift value is introduced into the calculation of the difference between the first prediction and the second prediction.
 15. The computing device of claim 10, calculating the first gradient values for the first prediction and the second gradient values for the second prediction further comprises calculating a horizontal gradient and a vertical gradient at each of a first prediction position of the first prediction and a second prediction position of the second prediction.
 16. The computing device of claim 10, wherein calculating the final bi-prediction of the current block comprises: calculating the final bi-prediction of the current block based further on a fourth right shift value for combining the first prediction and the second prediction.
 17. The computing device of claim 16, wherein the fourth right shift value comprises an additional right shift value, and wherein the additional right shift value is set to be equal to a bit-depth of a video for decoding.
 18. The computing device of claim 10, wherein the first prediction is determined based on a first motion vector from the current block to the first reference picture, and wherein the second prediction is determined based on a second motion vector from the current block to the second reference picture.
 19. A non-transitory computer readable storage medium storing a plurality of programs for execution by a computing device having one or more processors, wherein the plurality of programs, when executed by the one or more processors individually or collectively, cause the computing device to perform acts to generate a video bitstream and store the generated video bitstream in the non-transitory computer readable storage medium, the acts comprising: obtaining a current block from a current picture; determining, for the current block of, a first prediction corresponding to a first reference picture, wherein the first reference picture is displayed before the current picture; determining, for the current block, a second prediction corresponding to a second reference picture, wherein the second reference picture is displayed after the current picture; calculating first gradient values for the first prediction and second gradient values for the second prediction; calculating a respective motion refinement of each subblock of the current block by minimizing a difference between the first prediction and the second prediction based on a motion refinement threshold and a plurality of internal parameters representing different summation characters of the first prediction and the second prediction; calculating a final bi-prediction of the current block based on the first prediction, the second prediction, respective motion refinements, the first gradient values and the second gradient values; and generating a video bitstream based on the final bi-prediction.
 20. The storage medium of claim 19, wherein calculating a respective motion refinement of each subblock of the current block by minimizing a difference between the first prediction and the second prediction comprises: calculating a horizontal summation by adding the first horizontal gradient and the second horizontal gradient, and calculating a vertical summation by adding the first vertical gradient and the second vertical gradient, wherein a first right shift value is introduced into the horizontal summation and the vertical summation for lowering a bit-width of each of the horizontal summation and the vertical summation; and calculating a respective motion refinement of each subblock of the current block based on the horizontal summation and the vertical summation. 